const request = require('request')
const axios = require('axios').default;

// function readRemoteFile(url) {
//     return new Promise((resolve, reject) => {
//         request.get(url, function (error, response, body) {
//             if (!error && response.statusCode == 200) {
//                 resolve(body)
//             } else {
//                 resolve()
//             }
//         });
//     })
// }


function readRemoteFile(url) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'get',
            url: encodeURI(url)
        })
            .then(function (response) {
                // console.log(response);
                if (response.status === 200) {

                    console.log(response.data);
                } else {
                    reject(new Error(`Request Failed,Status Code: ${response.status}`))
                    // logger.error('doRequest error: ', `Request Failed,Status Code: ${response.status}`)
                }
            })
            .catch(function (error) {
                //   logger.error('download error: ', error.message)
                reject(error);
            });

    })
}

async function main() {


    const version = await readRemoteFile('https://gitee.com/523757325/torrent-manager-node/raw/master/src/.version')
    

    console.log(version);
}

main()